package cn.zniot.so.apiprovide.business;

import java.util.Map;

import cn.zniot.so.database.DBManager;

public class LoginHandler extends AbstractHandler {
	private Response response = null;
	public String username;
	public String password;
	private String userId;// box的id号

	/**
	 * 方法名：handle(Map<String, String> params) 
	 * 功　能：根据用户名和密码查询数据库返回id号的xml文件
	 * 参　数：Map<String, String> params - &参数键值对 
	 * 返回值：String - &xml文件包含头文件和实体内容
	 */
	public String handle(Map<String, String> params) {
		userId= loadDbParserParmeter(params);
		response = new LoginResponse(userId);
		String xmlStr = pageMaker(response.toJsonPage());
		return xmlStr;
	}

	/**
	 * 方法名：loadDbParserParmeter(Map<String, String> params) 
	 * 功　能：&功能说明
	 * 参　数：Map<String, String> params -&输入参数键值对 
	 * 返回值：String - &返回车机id号
	 */
	public  String loadDbParserParmeter(Map<String, String> params) {
		username = params.get("username");
		password = params.get("password");
		userId = DBManager.getInstance().simpleLogin(username, password);
		return userId;
	}
}
